import request from "@/api/index"

export default {
  /**
   * @description: 添加用户 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  add (params) {
    const url = "userManagement/user/add"
    return request.post(url, {
      ...params,
      homeBaseType: '1'
    })
  },
  /**
   * @description: 编辑用户 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  edit (params) {
    const url = "userManagement/user/edit"
    return request.post(url, params)
  },
  /**
   * @description: 删除用户 *代表必填
   * @param {String/Number} staffId *
   * @return {Object}
   */
  delById (params) {
    const url = "/userManagement/user/delById"
    return request.get(url, params)
  },
  delByListId (params) {
    const url = "userManagement/user/delListById"
    return request.get(url, params)
  },
  /**
   * @description: 条件查询用户 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  queryByCondition (params) {
    const url = "userManagement/user/queryByCondition"
    return request.post(url, params)
  },
  /**
   * @description: 条件查询去除超级管理员 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  queryByConditionRemoveAdmin (params) {
    const url = "userManagement/user/queryByConditionRemoveAdmin"
    return request.post(url, params)
  },
  /**
   * @description: 分页查询用户 *代表必填
   * @param {Object} params *
   * @param {String/Number} page *
   * @param {String/Number} size *
   * @return {Object}
   */
  queryPageByCondition (params) {
    const url = "userManagement/user/queryPageByCondition"
    return request.post(url, {
      ...params,
    })
  },
  /**
   * @description: 禁用用户 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  forbidden (params) {
    const url = "userManagement/user/forbidden"
    return request.get(url, params)
  },
  /**
   * @description: 取消用户禁用状态 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  cancelForbidden (params) {
    const url = "userManagement/user/cancelForbidden"
    return request.get(url, params)
  },
  /**
   * @description: 重置密码 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  resetPassword (params) {
    const url = "userManagement/user/resetPassword"
    return request.get(url, params)
  },
  /**
   * @description: 更换密码 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  updatePassword (params) {
    const url = "userManagement/user/updatePassword"
    return request.post(url, params)
  },
  /**
   * @description: 用户登录 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  userLogin (params) {
    const url = "userManagement/user/userLogin"
    return request.post(url, params)
  },
  /**
   * @description: 查询拥有指定角色的用户 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  queryListByRoleId (params) {
    const url = "userManagement/user/queryListByRoleId"
    return request.get(url, params)
  },
  /**
   * @description: 为用户分配角色 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  addRoleList (params) {
    const url = "userManagement/user/addRoleList"
    return request.post(url, params)
  },

  // --- 权限相关接口 -------------------------------------------------------------
  /**
   * @description: 给用户分配功能权限 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  addFunctionList (params) {
    const url = "userManagement/user/addFunctionList"
    return request.post(url, params)
  },
  /**
   * @description: 通过用户Id查询用户包括角色的所有功能权限列表 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  queryUserAllFuncList (params) {
    const url = "userManagement/user/queryUserAllFuncList"
    return request.get(url, params)
  },
  /**
   * @description: 通过用户id查询用户本身的功能权限列表 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  queryUserFuncList (params) {
    const url = "userManagement/user/queryUserFuncList"
    return request.get(url, params)
  },
  /**
   * @description: 获取当前登录用户菜单 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  getLoginUser (params) {
    const url = "userManagement/user/getLoginUser"
    return request.get(url, params)
  },
  /**
   * @description: 通过用户Id查询用户包括角色的指定类别的功能权限列表 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  queryUserAllFuncListByFuncType (params) {
    const url = "userManagement/user/queryUserAllFuncListByFuncType"
    return request.get(url, params)
  },
  /**
   * @description: 通过用户Id查询用户包括角色的指定类别的功能权限列表 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  queryAllFuncList (params) {
    const url = "userManagement/functionPermission/queryTreeByFuncType"
    return request.get(url, params)
  },
  /**
   * @description: 通过用户Id查询用户包括角色的所有权限 *代表必填
   * @param {Object} params *
   * @return {Object}
   */
  queryAllPermissionList (params) {
    const url = "/userManagement/user/getLoginUser"
    return request.get(url,params)
  },
}
